from langchain_core.runnables import RunnableConfig
from langgraph.runtime import Runtime

from video_summarize_tools.data_models import RuntimeContext, State, SourceUrlType


def source_url_conditional_edge(state: State, config: RunnableConfig, runtime: Runtime[RuntimeContext]):
    if state["source_url_type"] == SourceUrlType.VIDEO_FILE:
        return "download_from_video_url"
    else:
        return "download_from_domain_url"

def analysis_boot_edge(state: State, config: RunnableConfig, runtime: Runtime[RuntimeContext]):
    if state["video_stream_file_path"] and state["audio_stream_file_path"]:
        return ["audio_transcript", "extract_video_keyframe"]
    elif state["video_stream_file_path"]:
        return "extract_video_keyframe"
    elif state["audio_stream_file_path"]:
        return "audio_transcript"
    else:
        raise ValueError("No video or audio stream found")